import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";

type data = {
  id?: number,
  name: string,
  status: number,
  note: string,
  sort: number,
  type: number
};

type search = {
  name: string,
  type: number,
  note: string,
  status: number,
  pageNumber: number,
  pageSize: number,
  sortName: string,
  sortType: number
}

type select = {
  type: number,
  status: number
}

// 路段列表
export const MapList = (params?: search) => {
  return http.request<Result>("get", "/api/map/List", { params });
};

// 新增路段
export const addMap = (data: data) => {
  return http.request<Result>("post", "/api/map/Add", { data });
};

// 修改路段
export const updateMap = (data: data) => {
  return http.request<Result>("post", "/api/map/Update", { data });
};

// 删除路段
export const delMap = (id: number) => {
  return http.request<Result>("post", `/api/map/Delete/${id}`, {});
};

// 查询地图下拉
export const GetAllMap = (params?: select) => {
  return http.request<arrayResult>("get", "/api/map/GetAllMap", { params });
};

// 修改状态
export const UpdateStatus = (params?: any) => {
  return http.request<arrayResult>("post", "/api/map/UpdateStatus", { params });
};

// 地图类型
export const mapType = (params?: any) => {
  return http.request<arrayResult>("get", `/api/Dict/ListByParentCode/mapType`, { params });
};

// 地图导入
export const ImportMap = (data?: any) => {
  return http.request<arrayResult>("post", "/api/map/ImportMap", { data });
};
